package com.gadgets.cm04.fileregix.controller;

import com.gadgets.cm04.fileregix.dto.FileRegixQueryDTO;
import com.gadgets.cm04.fileregix.pojo.FileRegixInfo;
import com.gadgets.cm04.fileregix.service.FileRegixLogic;
import com.gadgets.framework.common.dto.HttpBaseResp;
import com.gadgets.framework.common.dto.Pagination;
import com.gadgets.framework.common.exception.GadgetsException;
import com.gadgets.framework.common.exception.GadgetsServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author UncleXiu
 * @version V1.0.0
 * @data 2020-09-16
 *
 */
@RestController
@RequestMapping(method = {org.springframework.web.bind.annotation.RequestMethod.POST,org.springframework.web.bind.annotation.RequestMethod.GET},value = "/fileRegix")
//@RoleAuthCheck
public class FileRegixController {

    @Autowired
    private FileRegixLogic fileRegixLogic;

    /**
     * 查询文件上传/下载规则（分页查询）
     * @param request                       请求信息
     * @param response                      应答信息
     * @param queryDTO                      查询条件
     * @param pagination                    分页条件
     * @return                              查询结果
     * @throws GadgetsServiceException      异常信息
     */
    @RequestMapping(method = {org.springframework.web.bind.annotation.RequestMethod.POST,org.springframework.web.bind.annotation.RequestMethod.GET},value = "/queryRegixInfo.do")
    //@RoleAuthCheck
    public HttpBaseResp<FileRegixInfo> queryFileRegixByCondition(
            HttpServletRequest request, HttpServletResponse response,
            FileRegixQueryDTO queryDTO, Pagination pagination
    ) throws GadgetsException {
        HttpBaseResp<FileRegixInfo> httpBaseResp = new HttpBaseResp<>();
        httpBaseResp.setPaging(pagination);
        httpBaseResp.setResultData(fileRegixLogic.queryFileRegixInfo(queryDTO, pagination));
        return httpBaseResp;
    }

}
